﻿@using Bifrost.Web.Mvc.Commands
@using Bifrost.Samples.Shop.Mvc.Features.Products
@using Bifrost.Samples.Shop.Mvc.Features.Shopping
@using Bifrost.Samples.Shop.Domain.Shopping

@model IEnumerable<Product>

@{
    View.Title = "All Products";
	var cartId = Guid.NewGuid();
}

<ul>

	@foreach (var product in Model) {
		<li>
			@product.Title - @product.Description

			@using( var form = (Html.BeginCommandForm<AddProductToCart, CartController>(c => c.Add(null), FormMethod.Post)) )
			{
				var command = new AddProductToCart() { Id = cartId, ProductId = product.Id };
	   
				@form.Html.HiddenFor(cmd => command.Id);
				@form.Html.HiddenFor(cmd => command.ProductId);
				<input type="submit" value="Add To Cart" />
			}
		</li>
	}
</ul>	
